<%@ include file="/common/taglibs.jsp"%>
<%@ taglib prefix="product" tagdir="/WEB-INF/tags/product"%>
<%@ taglib prefix="system" tagdir="/WEB-INF/tags/system"%>
<%@ taglib prefix="customer" tagdir="/WEB-INF/tags/customer"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<head>
	<title><fmt:message key="csFavorite.favorite" /></title>
</head>
<content tag="position">
	<fmt:message key="accountMenu.businessManager" /> &gt; <b><fmt:message key="csFavorite.favorite" /></b>
</content>

<div class="fav_filter">
	<p><b><fmt:message key="csFavorite.tip.0" /></b></p>
	<p><fmt:message key="csFavorite.tip.1" /></p>
	<p><fmt:message key="csFavorite.tip.2" /></p>
	<ins></ins>
</div>
<div class="one_tab">
	<div class="tab_05">
		<ul class="content clearfix">
			<li class="curr"><span><fmt:message key="csFavorite.favoriteProduct" /></span></li>
		</ul>
	</div>
</div>
<form name="favoriteListForm" method="post" action="${ctxPath}/customer/csFavorites.html">
<input type="hidden" name="doAction" value="defaultAction" />
<div class="fav_window">
	<div class="content clearfix">
		<c:if test="${not empty favoriteList}">
		<ul>
			<c:forEach items="${favoriteList}" var="favorite" varStatus="status">
			<li>
				<div class="choose"><input type="checkbox" name="multiIds" value="${favorite.favoriteId}" /></div>
				<div class="img">
					<product:productImage product="${favorite.product}" linkType="1" sizeType="s1"/>
				</div>
				<div class="name">
					<h4><a href="<product:productUrl product="${favorite.product}"/>" title="${favorite.product.productName}">${favorite.product.productName}</a></h4>
					<p>${favorite.product.productDescription.shortDescription}</p>
					<div class="ft clearfix">
						<span class="time"><fmt:message key="csFavorite.favoriteTime" /><fmt:formatDate value="${favorite.createTime}" pattern="yyyy-MM-dd"/></span>
					</div>
				</div>
				<div class="info">
					<div class="price">
						<product:productPrice productSku="${favorite.product.defaultProductSku}" multiple="true" hasPriceName="true"/>
					</div>
					<div class="rank">
						<fmt:formatNumber var="score" value="${favorite.product.productStat.reviewScore}" pattern="0.0"/>
						<customer:scoreStar value="${score}"/>
						<span>
							<a href="<customer:productReviewUrl product="${favorite.product}"/>" target="_blank">
								<fmt:message key="productDetail.onshowReviewCount.title">
									<fmt:param>${favorite.product.productStat.onShowReviewCount}</fmt:param>
								</fmt:message>
							</a>
						</span>
					</div>
					<div class="do">
					<c:if test="${empty favorite.product.minOrderQuantity}">
						<a href="javascript:void(0)" onclick="addToCart('${favorite.product.defaultProductSku.productSkuCode}', null, 1, function(){window.location.href='${ctxPath}/checkout.html'});" class="buy"><fmt:message key="csFavorite.buyNow" /></a> 
						<a href="javascript:void(0)" onclick="addToCart('${favorite.product.defaultProductSku.productSkuCode}', null, 1);" class="add"><fmt:message key="csFavorite.addFavorite"/></a>
					</c:if>
					<c:if test="${not empty favorite.product.minOrderQuantity}">
						<a href="javascript:void(0)" onclick="addToCart('${favorite.product.defaultProductSku.productSkuCode}', null, ${favorite.product.minOrderQuantity}, function(){window.location.href='${ctxPath}/checkout.html'});" class="buy"><fmt:message key="csFavorite.buyNow" /></a> 
						<a href="javascript:void(0)" onclick="addToCart('${favorite.product.defaultProductSku.productSkuCode}', null, ${favorite.product.minOrderQuantity});" class="add"><fmt:message key="csFavorite.addFavorite"/></a>
					</c:if>
					</div>
				</div>
			</li>
			</c:forEach>
		</ul>
		</c:if>
	</div>
	<div class="all">
		<label><input type="checkbox" name="allbox" onclick="checkAll(this.form)" /> <fmt:message key="csFavorite.sellectAll"/></label> 
		<a href="javascript:void(0);multiDelete();return false;" onclick="multiDelete();return false;" class="do"><fmt:message key="csFavorite.cancelFavorite"/></a>
	</div>
</div>
<div class="page_bottom clearfix">
	<div class="pagination">
		<div style="display:none;">
			<%@ include file="../common/pagingOnlyTop.jsp"%>
		</div>
		<%@ include file="../common/pagingOnly.jsp"%>
	</div>
</div>	
</form>
<script>
	function multiDelete() {
		var theForm = document.forms["favoriteListForm"];
		var paramData = $j(":input[name='multiIds']").serializeArray();
		if (paramData.length > 0) {
		} else {
			alert("<fmt:message key="csFavorite.chooseCancelFavorite"/>");	 
			return;
		}
		
		theForm.doAction.value = "multiDelete";
		theForm.submit();
		
		function afterPost(data) {
			window.location.reload();
		}
		//$j.post("${ctxPath}/customer/csFavorites.html?doAction=multiDelete", paramData, afterPost, "json");
	}
	
	function checkAll(theForm) { // check all the checkboxes in the list
		for (var i=0;i<theForm.elements.length;i++) {
	    	var e = theForm.elements[i];
			var eName = e.name;
	    	if (eName != 'allbox' && (e.type.indexOf("checkbox") == 0)) {
	        	e.checked = theForm.allbox.checked;		
			}
		} 
	}
</script>